﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bussiness;

namespace EWebsite.Admin.Feedback {
    public partial class Default : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            if (!IsPostBack) {
                PartnerBuss partner = new PartnerBuss();
                drpPartner.DataTextField = "PartnerLoginName";
                drpPartner.DataValueField = "PartnerID";
                drpPartner.DataSource = partner.getPartnerList();
                drpPartner.DataBind();

                //
                TransactionBuss buss = new TransactionBuss();
                grvFeedback.DataSource = buss.getPendingTransaction();
                grvFeedback.DataBind();

                //load city

            }
        }

        /// <summary>
        /// cancel transaction
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCancel_Command(object sender, CommandEventArgs e) {
            //login
            //call ws1            
            object[] arr = new object[] { "name", "password" };
            object obj = WSProxy.CallWebService("http://localhost:65118/PublisherWS.asmx", "PublisherWS", "WSLogin", arr);
            String SID = obj.ToString();

            //call ws refuse
            //get transID
            //int transID = int.Parse((Label)grvFeedback.Rows[
            //String catName = ((TextBox)grvCategories.Rows[index].FindControl("txtCatName")).Text.Trim();
        }

        protected void drpPartner_SelectedIndexChanged(object sender, EventArgs e) {
            if (!IsPostBack) {
                int partnerID = 0;
                try{
                    partnerID = int.Parse(drpPartner.SelectedValue);
                }catch(Exception ex){
                    return;
                }
                TransactionBuss buss = new TransactionBuss();
                grvFeedback.DataSource = buss.getPendingTransaction(partnerID);
                grvFeedback.DataBind();
            }            
        }

        protected void btnView_Click(object sender, EventArgs e) {
            int partnerID = 0;
            try {
                partnerID = int.Parse(drpPartner.SelectedValue);
            }
            catch (Exception ex) {
                return;
            }
            TransactionBuss buss = new TransactionBuss();
            grvFeedback.DataSource = buss.getPendingTransaction(partnerID);
            grvFeedback.DataBind();
        }

    }
}